<template>
	<view class="container-investment">
		<view class="lang-top-view">
			<view class="lang-top">
				<view class="backIcon" @click="back()">
					<uni-icons type="left" size="26" color="#fff"></uni-icons>
				</view>
				<view class="langText">
					{{$t('我的投资')}}
				</view>
				<view class="clearView"></view>
			</view>
			<view class="top-text">
				<view class="width33">
					<p>$<span>{{user.bj}}</span></p>
					<p class="margin5">{{$t('待收本金')}}</p>
				</view>
				<view class="width33">
					<p>$<span>{{user.dslx}}</span></p>
					<p class="margin5">{{$t('待收利息')}}</p>
				</view>
				<view class="width33">
					<p>$<span>{{user.sy}}</span></p>
					<p class="margin5">{{$t('累计收益')}}</p>
				</view>
			</view>
		</view>
		<view class="content-view">
			<p>{{$t('投资记录')}}</p>
			<view class="nodata-text" v-if="contentList.length == 0">
				{{$t('暂无投资记录')}}
			</view>
			<view v-else class="item-list" v-for="(item,index) in contentList" :keys="index">
				<view  class="de_wrap">
					<p  class="tit">
					<span>{{item.title}}</span>
					<span v-if="item.status== 0">（{{$t('进行中')}}）</span>
					<span v-if="item.status== 1">（{{$t('已完成')}}）</span>
					</p>
					<p  class="time">{{item.create_at}}</p>
				</view>
				<view class="price">$<span>{{item.money}}</span></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				user:{},
				contentList:[]
			}
		},
		onShow() {
			this.getinfo2()
			this.getlist()
		},
		methods:{
			getlist(){
				this.$http.get(
					'api/order/index',//接口名
					{},//参数合集
					{},
					false
				).then(res=>{
					this.contentList = res.data.data.data
					console.log(this.contentList)
				},(err)=>{//失败的操作
					uni.showToast({
						icon: 'error',
						title: err.data.message
					});
				})
			},
			getinfo2(){
				this.$http.get(
					'api/user/infos',//接口名
					{},//参数合集
					{},
					false
				).then(res=>{
					this.user = res.data
				},(err)=>{//失败的操作
					uni.showToast({
						icon: 'error',
						title: err.data.message
					});
				})
			},
			back(){
				uni.switchTab({
					url:'/pages/my/index'
				})
			},
		}
	}
</script>

<style scoped>
	.price{
	    flex: 1;
	    font-size: 20px;
	    line-height: 28px;
	    font-weight: 700;
	    text-align: right;
	    color: #f12211;
	    white-space: nowrap;
	}
	.price2{
	    flex: 1;
	    font-size: 20px;
	    line-height: 28px;
	    font-weight: 700;
	    text-align: right;
	    color: green;
	    white-space: nowrap;
	}
	.time{
		font-size: 12px;
		color: rgba(0, 0, 0, .8);
		line-height: 17px;
		margin-top: 10px
	}
	.tit{
	    font-size: 14px;
	    color: rgba(0, 0, 0, .8);
	    line-height: 20px;
	    font-weight: 700;
	}
	.de_wrap{
		flex:2;
	}
	.item-list{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 16px 8px;
		border-bottom: 1px solid #ececec;
	}
	.container-vip{
		background-color: #f6f6f6;
	}
	.lang-top{
		display: flex;
		padding-left:10rpx;
		height:88rpx;
		line-height:88rpx;
		background-color: #0a5;
	}
	.backIcon{
		width:20%;
	}
	.langText{
		font-size:36rpx;
		width:60%;
		text-align: center;
		
	}
	.clearView{
		width:20%;
	}
	.lang-top-view{
		height:312rpx;
		background-color: #0a5;
		color:#fff;
	}
	.top-text{
		display: flex;
		justify-content: center;
		align-items: center;
		text-align: center;
		margin-top:50rpx;
		
	}
	.width33{
		width:33.33%;
		font-size: 28rpx;
		font-weight: 600;
	}
	.margin5{
		margin-top:10rpx;
	}
	.content-view{
		padding: 10rpx;
		margin: 0 auto;
		font-size:24rpx;	
	}
	.content-view>p{
		width: 100%;
		line-height: 88rpx;
		height: 88rpx;
		font-size: 28rpx;
		color: #000;
		padding: 0 28rpx;
		background: #fafafa;
		font-size: 28rpx;
		font-weight: 600;
	}
	.nodata-text{
		margin-top: 12rpx;
		padding: 0 120rpx;
		color: #969799;
		font-size: 28rpx;
		line-height: 40rpx;
		text-align: center;
	}
</style>